home *** CD-ROM | disk | FTP | other *** search
- Path: news.ov.com!news
- From: glenn@ov.com (Fletcher.Glenn@ov.com)
- Newsgroups: comp.lang.c
- Subject: Re: HELP!!!!!!!
- Date: 5 Feb 1996 18:06:57 GMT
- Organization: OpenVision
- Message-ID: <4f5h01$oll@spanky.pls.ov.com>
- References: <3112CFDA.85@utoronto.ca>
- Reply-To: glenn@ov.com
- NNTP-Posting-Host: foghorn.pls.ov.com
-
- In article 85@utoronto.ca, Dave Goldstein <dave.goldstein@utoronto.ca> writes:
- >I am a frustrated new C programmer, with a big headache:
- >I've composed a linked list in a function, and I am passing the HEAD of
- >the list into the function. Of course, when I pass this into the
- >function, I have to dereference it twice (**head) since I pass it in as
- >&head. Anyway, to make a long story short, when I try accessing the
- >first item in the linked list (assuming there is one), I have tried
- >accessing it as **head->next which C doesn't seem to like. WHY????!!
- >It keeps giving me an error "Pointer to structure required on left side
- >of -> or ->* in function ....". Isn't that what I'm doing??
- >
- >Please help, I'm beginning to feel suicidal!
- >If you wish to mail me please write to:
- >
- >dave.goldstein@utoronto.ca
- >
- >I'll be forever in your debt! Thanks.
-
-
- Remember the -> operator is just like using *. i.e.
- head->next is the same as
- (*head).next
-
- Since you are using &head as a function argument, then you need to
- use *head->next to get the pointer to the next element in your
- linked list.
-
- BTW, if you are not planning to modify the contents of head, then you
- can use the value directly. If you are planning to modify head, then
- you are doing the correct thing.
-
- Fletcher.Glenn@ov.com
-
-
-